package com.sakiko.rag.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.QuestionAnswerAdvisor;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * projectName: com.sakiko.rag.controller
 *
 * @author: Yang
 * description: rag test
 * time: 2025/8/9 16:37
 */
@RestController
public class RAGController {

    @Autowired
    ChatClient client;

    @Autowired
    VectorStore vectorStore;

    @GetMapping("/rag")
    public String rag(String input) {
        String content = client.prompt()
                .user(input)
                .advisors(new QuestionAnswerAdvisor(vectorStore))
                .call()
                .content();
        System.out.println("content = " + content);
        return content;
    }
}
